// https://www.acwing.com/problem/content/description/797/

#include <vector>
#include <iostream>
using namespace std;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int m, n;
    cin>>m>>n;

    vector<int> sum(m+1, 0);
    int tmp_sum = 0;
    for (int i=0; i<m; i++) {
        int tmp;
        cin>>tmp;
        tmp_sum += tmp;
        sum[i+1] = tmp_sum;
    }

    while (n-->0) {
        int from, to;
        cin>>from>>to;
        cout<<sum[to]-sum[from-1]<<endl;
    }

    return 0;
}
